<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  

  <script>
      class User {
        // constructor(fname,lname,age){
        //     this.fname = fname;
        //     this.lname = lname;
        //     this.age = age
        // }
      }

      function classProxy(Class,...propNames){
        return new Proxy(Class,{
            construct(target,argumentsList){
                console.log(argumentsList)
                console.log(propNames)
                const obj =   Reflect.construct(target,argumentsList)
                propNames.forEach((el,i) => {
                  obj[el] = argumentsList[i]
                });
                return obj
              
            }
        })
      }

      const userProxy = classProxy(User,'fname','lname','age')

      const user1 = new userProxy(1,2,3)
      const user2 = new userProxy(1,2,3)
      console.log(user1)
      user1.fname = 2222
      console.log(user1)
      console.log(user2)

  </script>
</body>
</html>